
function setCookie(name,value,expiresDate){
	var cookieText=encodeURIComponent(name)+"="+encodeURIComponent(value);
		if(expiresDate instanceof Date){
			cookieText+=";expires="+expiresDate;
		}
		document.cookie=cookieText;
		
}
//function setCookie(name,value,expiresDate){
//	
//	var cookieText = encodeURIComponent(name) + '=' + encodeURIComponent(value);
//	//instanceof判断一个对象是否属于日期类型
//	if(expiresDate instanceof Date){
//		cookieText += ';expires=' + expiresDate;
//	}
//	//保存到cookie中
//	document.cookie = cookieText;
//}
//function getCookie(name){
//	var  cookieText=decodeURIComponent(document.cookie);
//	var arr1=cookieText.split(';');
//	for(var i=0;i<arr1.length;i++){
//		var arr2=arr1[i].split('=');
//		if(arr2[0]==name){
//			return arr2[1];
//		}
//	}
//}
function getCookie(name){
	
	var cookieText = decodeURIComponent(document.cookie);
	//分割
	var arr1 = cookieText.split('; ');
	//遍历2次分割
	for(var i = 0; i < arr1.length;i++){
		
		var arr2 = arr1[i].split('=');
		if(arr2[0] == name){
			
			return arr2[1];
		}
	}
}
function removeCookie(name){
	document.cookie=encodeURIComponent(name)+'=;expires='+new Date();
}
